﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;

public partial class YL_Travels : System.Web.UI.Page
{

    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly TravelLinesBLL bllTravelLines = new TravelLinesBLL();
    public Category model = new Category();
    int count = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }

    #region 分页绑定
    private void InitData(int PageIndex)
    {
        DataSet ds = new DataSet();
        string where = "1=1";
        int cityid = 0;
        if (Request.QueryString["PID"] != null)
        {
            //try
            //{
            //    where = "title like '%" + StringUtil.HtmlEncode(Request.QueryString["SKey"] + "") + "%'";
            //}
            //catch
            //{
            //    where = "";
            //}
            try
            {
                cityid = int.Parse(Request.QueryString["PID"] + "");
            }
            catch
            {
                cityid = 0;
            }
            if (cityid != 0)
            {
                model = bllCategory.GetModel(cityid);
                this.Title += "-" + model.title;
            }
        };


        ds = bllTravelLines.GetWebList(AspNetPager1.PageSize, PageIndex, "", "hhyl",cityid, out count);
        AspNetPager1.RecordCount = count;

        this.rptContent.DataSource = ds.Tables[0].DefaultView;
        this.rptContent.DataBind();
    }
    #endregion

    #region 分页控件加载
    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                InitData(e.NewPageIndex);
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
    #endregion

    #region 设置图片
    public string GetPic(object obj)
    {
        try
        {
            if (string.IsNullOrEmpty(obj + ""))
            {
                obj = "images/nopic.jpg";
            }
            else
            {
                obj = "uploads/" + obj;
            }
        }
        catch
        {
            obj = "images/nopic.jpg";
        }

        return obj + "";
    }
    #endregion

}
